﻿using UnityEngine;
using System.Collections;

namespace Battle
{
    public class ResultPanelLoader : MonoBehaviour
    {
        public string prefabPath;

        void OnEnable()
        {
            Load();
        }

        void OnDisable()
        {
            Unload();
        }

        void Load()
        {
            var prefab = AssetLoad.ResourceManager.Instance.LoadResource(prefabPath) as GameObject;
            var obj = GameObject.Instantiate(prefab) as GameObject;
            obj.transform.SetParent(transform);
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale = Vector3.one;
            obj.transform.localEulerAngles = Vector3.zero;
        }

        void Unload()
        {
            foreach (Transform trans in transform)
            {
                GameObject.Destroy(trans.gameObject);
            }
        }


    }
}